{% extends "admin/base_site.html" %}
{% load i18n %}

{% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% load adminmedia %}{% admin_media_prefix %}css/dashboard.css" />{% endblock %}

{% block coltype %}colMS{% endblock %}

{% block bodyclass %}dashboard{% endblock %}

{% block breadcrumbs %}<div class="breadcrumbs"><a href="/admin/">Accueil</a> > Modifier l'ordre des scènes</div>{% endblock %}

{% block content %}

<div style="width: 40%; float: left;margin-right: 10%;">		
    <h3>Ordre des scènes</h3>

    <form method='post' action='' id='formOngletTop'><table style="width: 100%;">{% csrf_token %}

        {% for map in maps %}
        <tr>
            <td style="width: 50px;">
                <a href="" onclick="ongletDownTop('{{ map.order }}'); return false;"><img src="{{ MEDIA_URL }}/images/admin/arrow-up.gif" alt="up"/></a> 
                <a href="" onclick="ongletUpTop('{{ map.order }}'); return false;"><img src="{{ MEDIA_URL }}/images/admin/arrow-down.gif" alt="down"/></a>
                
            </td>

            <td><input id='top{{ map.order }}' type="hidden" name="{{ map.order }}" value="{{ map.order }}" />{{ map.name }}</td>
        </tr>
        {% endfor %}
        <input type="hidden" name="maps" value="order">
    </table></form>
</div>

<div id="admin_bouton_logout" style="clear: both;">
    <form action="/admin/" method="GET">
        <input type="submit" value="Retour Administration" />
    </form>
</div>


<script type="text/javascript">
function ongletUpTop(num)
{
    var tmp=parseInt(num)+1;
    
    num = 'top'+num;
    tmp = 'top'+tmp;
    if(document.getElementById(tmp)) 
    {
        document.getElementById(num).value = parseInt(document.getElementById(num).value)+1;
        document.getElementById(tmp).value = parseInt(document.getElementById(tmp).value)-1;
        document.getElementById('formOngletTop').submit();
    }
}

function ongletDownTop(num)
{
    var tmp=parseInt(num)-1;
    
    num = 'top'+num;
    tmp = 'top'+tmp;
    if(document.getElementById(tmp)) 
    {        
        document.getElementById(num).value = parseInt(document.getElementById(num).value)-1;
        document.getElementById(tmp).value = parseInt(document.getElementById(tmp).value)+1;
        document.getElementById('formOngletTop').submit();
    }
}
</script>

{% endblock %}
